<?php
namespace Wx\Controller;
use Think\Controller;
/*
*消息中心
*/
class MessageController extends CommonController {
    public function index(){
        $this->show('PC端等待资金注入','utf-8');
    }
	//评论消息列表
	public function voice(){
		$comments=D('comments');
		$user=D('user');
		$user_info=D('user_info');
		if(!session('uid'))$this->error('未登录！');
		$getall=$comments->where("r_u_id=".session('uid'))->order('id desc')->select();
		foreach($getall as $i=>$one){
			//状态设置为0
			$comments-> where('id='.$one['id'])->setField('state',0);
			//该评论用户昵称和头像
			$getuser=$user->where("id=".$one['u_id'])->find();
			$getinfo=$user_info->where("u_id=".$one['u_id'])->find();
			$getall[$i]['nickname']=$getuser['nickname'];
			$getall[$i]['u_img']=$getinfo['img'];
			//找到被评论的文章或者言论
			if($one['r_id']==0){
				//找出文章
				$table='arc_'.$one['arc_type'];
				$arc=D($table);
				$getarc=$arc->where("id=".$one['arc_id'])->find();
				$getall[$i]['my_title']=$getarc['title'];
				}else{
					//找出评论
					$getone=$comments->where("id=".$one['r_id'])->find();
					$getall[$i]['my_title']=$getone['content'];
				}
			
		}//end for
		$this->assign('all',$getall);
		$this->display('voice');
	}//end fun
}